﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PLM.ConfigurationCenter.Backup.CustomForms {
    public partial class LoaderForm : Form {
        public LoaderForm() {
            InitializeComponent();
        }

        private void LoaderForm_Load(object sender, EventArgs e) {
            this.Opacity = 1;
        }
        /// <summary>
        /// 关闭命令
        /// </summary>
        public void closeOrder() {
            if (this.InvokeRequired) {
                //这里利用委托进行窗体的操作，避免跨线程调用时抛异常，后面给出具体定义
                CONSTANTDEFINE.SetUISomeInfo UIinfo = new CONSTANTDEFINE.SetUISomeInfo(new Action(() => {
                    while (!this.IsHandleCreated) {
                        ;
                    }
                    if (this.IsDisposed)
                        return;
                    if (!this.IsDisposed) {
                        this.Dispose();
                    }

                }));
                this.Invoke(UIinfo);
            } else {
                if (this.IsDisposed)
                    return;
                if (!this.IsDisposed) {
                    this.Dispose();
                }
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void loading_FormClosing(object sender, FormClosingEventArgs e) {
            if (!this.IsDisposed) {
                this.Dispose(true);
            }

        }
    }
    class CONSTANTDEFINE {
        public delegate void SetUISomeInfo();
    }



}
